package com.mrjy.integral.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mrjy.common.entity.IntegralInfo;
import com.mrjy.integral.bo.IIntegralInfoBo;

@Controller
@RequestMapping("integral/integralInfo")
public class IntegralInfoController{
	@Resource
	private IIntegralInfoBo integralInfoBo;
	
	/**
	 * 添加
	 * @return
	 */
	@RequestMapping("/add")
	@ResponseBody
	public Object add(IntegralInfo info){
		return integralInfoBo.txInsert(info);
	}
	/**
	 * 根据ID查询
	 * @return
	 */
	@RequestMapping("/queryById")	
	@ResponseBody
	public Object queryById(int schoolId) {
		return integralInfoBo.queryById(schoolId);
	}
	/**
	 * 修改
	 * @param userInfo
	 * @return
	 */
	@RequestMapping("/edit")
	@ResponseBody
	public Object edit(IntegralInfo info) {		
		return integralInfoBo.txUpdateById(info);
	}
	
	/**
	 * 删除
	 * @param ids
	 * @return
	 */
	@RequestMapping("/deleteByIds")
	@ResponseBody
	public Object deleteByIds(int[] ids) {		
		return integralInfoBo.deleteByIds(ids);
	}
	/**
	 * 禁用、起用
	 * @param ids
	 * @return
	 */
	@RequestMapping("/updateDisableFlag")
	@ResponseBody
	public Object updateDisableFlag(IntegralInfo info) {		
		return integralInfoBo.updateDisableFlag(info);
	}
	
	/**
	 * 通过userId查询其累计积分
	 * @param info
	 * @return
	 */
	@RequestMapping("/queryPageByUserId")
	@ResponseBody
	public Object queryPageByUserId(IntegralInfo info,HttpSession session) {		
		return integralInfoBo.queryPageByUserId(info,session);
	}
	
	/**
	 * 完整观看一个视频，增加30积分
	 * @param info.userId 用户id info.infoId 视频id
	 * @return
	 */
	@RequestMapping("/addVideoIntegralByUserId")
	@ResponseBody
	public Object addVideoIntegralByUserId(IntegralInfo info) {		
		return integralInfoBo.addVideoIntegralByUserId(info);
	}
	
	/**
	 * 微信1.6.4 查询积分排行榜
	 * @param info
	 * @return
	 */
	@RequestMapping("/queryIntegralRank")
	@ResponseBody
	public Object queryIntegralRank(IntegralInfo info,HttpSession session) {		
		return integralInfoBo.queryIntegralRank(info,session);
	}
}
